package org.idea.spring.aop.version1;

import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import org.idea.spring.aop.version1.annotation.Aspect;

import java.io.IOException;
import java.util.List;

/**
 * @Author linhao
 * @Date created in 3:41 下午 2021/5/6
 */
public class Demo {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        final ClassPath classPath  = ClassPath.from(Demo.class.getClassLoader());
        ImmutableSet<ClassPath.ClassInfo> clazz = classPath.getAllClasses();
        List<ClassPath.ClassInfo> list = clazz.asList();
        for (ClassPath.ClassInfo classInfo : list) {
            if(classInfo.getName()!=null && classInfo.getPackageName().contains("org.idea.spring.aop")){
                Class clazzTemp = Class.forName(classInfo.getName());
                if(clazzTemp.isAnnotationPresent(Aspect.class)){
                    System.out.println(classInfo.getName());
                }
            }
        }
    }
}
